package com.saltlux.storm.study.bbs;

import java.util.Map;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;

public class BoardDTO implements DTO {

	private String id;
	private String title;
	private String description;
	private String createdAt;
	private String createdBy;
	private String lastModifiedAt;
	private String lastModifiedBy;
	
	public BoardDTO() {
		super();
	}
	
	public static BoardDTO valueOf(Map<String, String> map) {
		BoardDTO boardDTO = new BoardDTO();
		boardDTO.setId(map.get("ID"));
		boardDTO.setTitle(map.get("TITLE"));
		boardDTO.setDescription(map.get("DESCRIPTION"));
		boardDTO.setCreatedAt(map.get("CREATEDAT"));
		boardDTO.setCreatedBy(map.get("CREATEDBY"));
		boardDTO.setLastModifiedAt(map.get("LASTMODIFIEDAT"));
		boardDTO.setLastModifiedBy(map.get("LASTMODIFIEDBY"));
		
		return boardDTO;
	}

	/**
	 * 
	 * @param title
	 */
	public BoardDTO(String title) {
		this(null, title, String.valueOf(""), String.valueOf(""), String.valueOf(""), String.valueOf(""), String.valueOf(""));
	}

	/**
	 * 
	 * @param id
	 * @param title
	 * @param description
	 * @param createdAt
	 * @param createdBy
	 * @param lastModifiedAt
	 * @param lastModifiedBy
	 */
	public BoardDTO(String id, String title, String description,
			String createdAt, String createdBy, String lastModifiedAt,
			String lastModifiedBy) {
		super();
		this.id = id;
		this.title = title;
		this.description = description;
		this.createdAt = createdAt;
		this.createdBy = createdBy;
		this.lastModifiedAt = lastModifiedAt;
		this.lastModifiedBy = lastModifiedBy;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getCreatedAt() {
		return createdAt;
	}

	public void setCreatedAt(String createdAt) {
		this.createdAt = createdAt;
	}

	public String getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(String createdBy) {
		this.createdBy = createdBy;
	}

	public String getLastModifiedAt() {
		return lastModifiedAt;
	}

	public void setLastModifiedAt(String lastModifiedAt) {
		this.lastModifiedAt = lastModifiedAt;
	}

	public String getLastModifiedBy() {
		return lastModifiedBy;
	}

	public void setLastModifiedBy(String lastModifiedBy) {
		this.lastModifiedBy = lastModifiedBy;
	}

	@Override
	public int hashCode() {
		return HashCodeBuilder.reflectionHashCode(this);
	}

	@Override
	public boolean equals(Object obj) {
		return EqualsBuilder.reflectionEquals(this, obj);
	}

	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}
}
